package com.gsafety.wellsfort.controller.course;

import com.gsafety.wellsfort.common.util.ApiResponse;
import com.gsafety.wellsfort.domain.dto.course.WorkFinishPreviewDTO;
import com.gsafety.wellsfort.domain.dto.course.WorkPublishDTO;
import com.gsafety.wellsfort.domain.dto.ids.WorkPublishIdDTO;
import com.gsafety.wellsfort.domain.dto.course.WorkPublishQueryDTO;
import com.gsafety.wellsfort.domain.vo.WorkFinishPreviewVO;
import com.gsafety.wellsfort.domain.vo.WorkPublishEditVO;
import com.gsafety.wellsfort.domain.vo.WorkPublishVO;
import com.gsafety.wellsfort.service.course.WorkPublishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "作业发布及发布记录管理",description = "作业发布及发布记录管理接口")
@RestController
@Slf4j
@RequestMapping("/api/wkpublish")
public class WorkPublishController {
    @Autowired
    WorkPublishService workPublishService;
    @ApiOperation(value="发布作业")
    @PostMapping("/publish-stuWk")
    public ApiResponse<WorkPublishDTO> publishStuWork(@RequestBody WorkPublishDTO workPublishDTO){
        return workPublishService.publishStuWork(workPublishDTO);
    }

    @ApiOperation(value="分页查询发布作业记录")
    @PostMapping("/list")
    public ApiResponse<List<WorkPublishVO>> listPublicWork(@RequestBody WorkPublishQueryDTO workPublishQueryDTO){

        return workPublishService.listPublishWork(workPublishQueryDTO);
    }

    @ApiOperation(value="编辑或预览发布作业记录")
    @PostMapping("/detail")
    public ApiResponse<WorkPublishEditVO> getPublicWorkDetail(@RequestBody WorkPublishIdDTO workPublishEditDTO){
        return workPublishService.getPublicWorkDetail(workPublishEditDTO);
    }

    @ApiOperation(value="取消发布作业")
    @PostMapping("/cancel")
    public ApiResponse<WorkPublishIdDTO> cancelWorkPublish(@RequestBody WorkPublishIdDTO workPublishEditDTO){

        return workPublishService.cancelWorkPublish(workPublishEditDTO);
    }
    @ApiOperation(value="再次发布作业")
    @PostMapping("/again-publish")
    public ApiResponse<WorkPublishIdDTO> againWorkPublish(@RequestBody WorkPublishIdDTO workPublishEditDTO){

        return workPublishService.againWorkPublish(workPublishEditDTO);
    }
    @ApiOperation(value="完成预览")
    @PostMapping("/finish-preview")
    public ApiResponse<WorkFinishPreviewVO> finishPreview(@RequestBody WorkFinishPreviewDTO workFinishPreviewDTO){

        return workPublishService.finishPreview(workFinishPreviewDTO);
    }
}
